package org.zhangyp.springbootsecurity.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zhangyp.springbootsecurity.model.dto.LoginDTO;
import org.zhangyp.springbootsecurity.model.dto.PhoneCodeDTO;
import org.zhangyp.springbootsecurity.result.Result;
import org.zhangyp.springbootsecurity.service.AuthService;

/**
 * todo
 *
 * @author ypzhang
 * @since 2025/5/28
 */
@RestController
@RequestMapping
public class LoginController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    public Result<String> login(@RequestBody LoginDTO loginDTO) {
        return authService.login(loginDTO);
    }

    @PostMapping("/logout")
    public Result<String> logout() {
        return authService.logout();
    }

    @PostMapping("/phoneCodeLogin")
    public Result<String> phoneCodeLogin(@RequestBody PhoneCodeDTO phoneCodeDTO) {
        return authService.phoneCodeLogin(phoneCodeDTO);
    }
}
